//
//  TRSMainViewController.m
//  TRSAnalytics
//
//  Created by 824810056 on 2018/1/19.
//  Copyright © 2018年 Miridescent. All rights reserved.
//

#import "TRSMainViewController.h"

#import "PageEventModelTableViewController.h"
#import "loginEventModelTableViewController.h"
#import "SendDeviceIDTableViewController.h"

#import "TRSAnalytics.h"


@interface TRSMainViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) NSArray  *cellArray;

@end

@implementation TRSMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"TRS";
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.cellArray = @[@"测试TRSPageEventConfig",@"测试登录登出方法",@"测试发送设备ID"];
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
    tableView.delegate = self;
    tableView.dataSource = self;
    
    [self.view addSubview:tableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.cellArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *mainCellIdentifier = @"mainCellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:mainCellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:mainCellIdentifier];
    }
    cell.textLabel.text = self.cellArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        
        
        NSMutableDictionary *dic = [@{@"se_name": @"进入111页面"} mutableCopy];
        
        [TRSAnalytics event:@"1111" properties:dic];
        
        PageEventModelTableViewController *controller = [[PageEventModelTableViewController alloc] init];
        [self.navigationController pushViewController:controller animated:YES];
    }
    if (indexPath.row == 1) {
        
        NSMutableDictionary *dic = [@{@"se_name": @"进入222页面"} mutableCopy];
        
        [TRSAnalytics event:@"2222" properties:dic];
        
        loginEventModelTableViewController *controller = [[loginEventModelTableViewController alloc] init];
        [self.navigationController pushViewController:controller animated:YES];
    }
    if (indexPath.row == 2) {
        
        [TRSAnalytics event:@"3333"];
        
        SendDeviceIDTableViewController *controller = [[SendDeviceIDTableViewController alloc] init];
        [self.navigationController pushViewController:controller animated:YES];
    }
    
}

@end
